package gameView;
import java.awt.*;
import java.awt.event.*;

import adapterLayer.Adapter;

/**
 * EventListeners.java
 * 
 * Fredrik Wallenius and Peter Steiner 
 * DP08 - KTH - 2009
 *
 */
public class EventListeners implements MouseListener, MouseMotionListener, KeyListener{
	
	private Adapter adapter;
	private Point p;
	private double renderFactor[];
	
	EventListeners(Adapter adapter_, double[] renderFactor_){
		this.adapter = adapter_;
		renderFactor = renderFactor_;
		
		
	}
	
	//Follows mouse when moved without holding any mousebuttons  
	public void mouseMoved(MouseEvent arg0) {
		Point pFactored = new Point();
		pFactored.x = (int) (arg0.getX() / renderFactor[0]);
		pFactored.y = (int) (arg0.getY() / renderFactor[1]);
		
		p = pFactored;
		
		if(adapter!=null){
			adapter.mouseControll(p);
		}
		
	}
	
	//Action on mouse click
	public void mouseClicked(MouseEvent arg0) {
		adapter.mouseClicked();
	}
	
	//Follows mouse when button pressed
	public void mouseDragged(MouseEvent arg0) {
	
	}
	
	public void keyPressed(KeyEvent ke) {
		adapter.keyPressed(ke);
		}
	public void keyReleased(KeyEvent ke) {
		adapter.keyReleased(ke);
	}
	public void keyTyped(KeyEvent ke) {
	}
	
	
	public void mouseEntered(MouseEvent arg0) {
	}
	public void mouseExited(MouseEvent arg0) {
	}
	public void mousePressed(MouseEvent arg0) {
	}
	public void mouseReleased(MouseEvent arg0) {
	}
	
	
}
